#include "App.h"
#include "include/cef_browser.h"
#include "include/views/cef_browser_view.h"
#include "include/views/cef_window.h"
#include "include/wrapper/cef_helpers.h"
#include "WindowDelegate.h"
#include "HttpSchemeFactory.h"
#include "CustomSchemeFactory.h"
#include "ViewDelegate.h"
#include "PageHandler.h"

void App::OnContextInitialized()
{
	CEF_REQUIRE_UI_THREAD();

	CefRegisterSchemeHandlerFactory("my", "test", new HttpSchemeFactory());
	//CefRegisterSchemeHandlerFactory("my", "test", new CustomSchemeFactory());

	std::string url = "my://test/index.html?a=123";
	CefRefPtr<PageHandler> pageHandler(new PageHandler());
	CefBrowserSettings browser_settings;
	CefRefPtr<ViewDelegate> viewDelegate(new ViewDelegate());
	CefRefPtr<CefBrowserView> browser_view = CefBrowserView::CreateBrowserView(pageHandler, url, browser_settings, nullptr, nullptr, viewDelegate);
	CefWindow::CreateTopLevelWindow(new WindowDelegate(browser_view, false));
}
